<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script type="text/javascript">
    /*
    * Object.defineProperty 是用于给对象定义属性操作
    * */
    const user1 = {
        id: 12,
        username: 'andy',
        age: 23,
    }
    console.log(user1.id);
    user1.age = 12;

    console.log(user1.age);

    const user2 = {}

    Object.defineProperty(user2, 'age', {
        get() {
            return 100;
        },
        set() {

            console.log('set');

        }
    })

    console.log(user2.age);

    user2.age = 1000;


</script>

</html>
